package cn.tedu.project.oa.base.config;

import cn.tedu.project.oa.base.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置类
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
          //暂时注释，方便调试，如果用的话请求头要带上Authorization （token）
        InterceptorRegistration registration = registry.addInterceptor(jwtInterceptor);
        registration.addPathPatterns("/**");
        registration.excludePathPatterns(
                "/swagger-resources/**",
                "/swagger-ui/**",
                "/v2/api-docs",
                "/webjars/**",
                "/oa/user/login",
                "/oa/user/logout",
                "/oa/user/login/captcha",
                "/oa/user/login/captcha",
                "/v1/file/upload",
                "/v1/file/remove",
                "/oa/asset/addNum",
                "/oa/announcement/addNum",
                "/oa/attendance/addNum",
                "/oa/asset/vehicle/addNum",
                "/oa/asset/repair/addNum",
                "/oa/note/addNum",
                "/oa/attendance/addNum");
    }
}
